<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Direct Interface (UVSOCK)</title>
<title>Using the µVision Socket Interface: Direct Interface (UVSOCK)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="drv.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="drv.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="keilarm.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Using the µVision Socket Interface
   &#160;<span id="projectnumber">Application Note 198</span>
   </div>
   <div id="projectbrief">Control and monitor µVision via the built-in TCP/IP interface</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
      <li><a href="modules.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('direct_sec.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Direct Interface (UVSOCK) </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The <b>UVSOCK</b> interface can be used directly, although this is recommended only for cases where the <a class="el" href="uvsc_sec.html">Client Interface (UVSC)</a> cannot be used, for example, when the client runs on an operating system other than Microsoft Windows.</p>
<p>The UVSOCK reference is avaialble in <a class="el" href="group__uvsock__interface.html">UVSOCK Interface (UVSOCK.h)</a>. Refer also to <a class="el" href="uvsock_messaging.html">UVSOCK Messaging</a>. Predefined data types are described in <a class="el" href="uvsock_data_types.html">UVSOCK Data Types</a>.</p>
<p>Follow these steps when working with <b>UVSOCK:</b> </p>
<ul>
<li><a class="el" href="direct_sec.html#enable_uvsock">Enable UVSOCK in uVision</a></li>
<li><a class="el" href="direct_sec.html#config_project">Configure a project</a></li>
<li><a class="el" href="direct_sec.html#build_project">Build a project</a></li>
<li><a class="el" href="direct_sec.html#debug_project">Debug a project</a></li>
<li><a class="el" href="direct_sec.html#evr_data">Accessing Event Recorder Data</a></li>
</ul>
<p>All possible operations are listed in <a class="el" href="group__operation__codes.html#ga99cef9125743ebfba84222416cdeb368">UV_OPERATION</a>.</p>
<h1><a class="anchor" id="enable_uvsock"></a>
Enable UVSOCK in uVision</h1>
<p>A.) Configure the TCP server port directly in uVision:</p>
<ol type="1">
<li>Select the menu <b>Edit &ndash;&gt; Configuration &ndash;&gt; Other</b></li>
<li>Enable <b>UVSOCK (TCP/IP) Settings</b></li>
<li>Set server <b>Port</b>, for example, to 4823.</li>
</ol>
<div class="image">
<img src="uvsock_tcpip_settings.png" alt="uvsock_tcpip_settings.png"/>
<div class="caption">
UVSOCK Configuration</div></div>
<p>B.) Alternatively, configure the TCP server port manually:</p>
<ol type="1">
<li>Open the file <b>TOOLS.INI</b> from the installation folder of uVision (by default, C:\Keil_v5)</li>
<li>In the section <b></b>[UV2] set the value for the entry <b>SOCKETPORT</b>. Setting <b>SOCKETPORT</b> to <b>0</b>, disables the interface.</li>
</ol>
<p><b>Example</b> </p>
<div class="fragment"><div class="line">[UV2]</div>
<div class="line">...</div>
<div class="line">SOCKETPORT=4823              <span class="comment">// =0 - disabled</span></div>
<div class="line">...</div>
</div><!-- fragment --><h1><a class="anchor" id="config_project"></a>
Configure a project</h1>
<p><em>Configuring</em> a project is the process of opening a <b>uVision</b> project and adding files to project groups. Complex configuration of a project is possible via the <b>uVision</b> IDE. To configure a project:</p>
<ul>
<li>Load an existing project with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368aedfffeed72c9e49bc68a2a34e210032f">UV_PRJ_LOAD</a></li>
<li>Optionally, add new project groups with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a01d7867d1620c7ee24d9226ad42e9ed6">UV_PRJ_ADD_GROUP</a></li>
<li>Optionally, add new files to a project groups with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a70cdeb9108b8886f089982eaf6c074c0">UV_PRJ_ADD_FILE</a></li>
</ul>
<h1><a class="anchor" id="build_project"></a>
Build a project</h1>
<p><em>Building</em> a project is the process of compiling and assembling source files, and linking the resultant object files to create an executable image. To build a project:</p>
<ul>
<li>Optionally, clean the project with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a08cb72025d4cf0cda1bda03d2eee898f">UV_PRJ_CLEAN</a></li>
<li>Build the project with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a5ef213bfdb2c6abdc5fd604cb06316e7">UV_PRJ_BUILD</a> or <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368ab6742feb96a4c1ff34e3f304d07565c6">UV_PRJ_REBUILD</a></li>
<li>Optionally, monitor the build output returned by the <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a5ab783fb4e2468a819301af06b188b19">UV_PRJ_BUILD_OUTPUT</a> message</li>
<li>Wait for the <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a5926c1d373fdb4efd1344692f119089d">UV_PRJ_BUILD_COMPLETE</a> message, and check the build result when received.</li>
</ul>
<h1><a class="anchor" id="debug_project"></a>
Debug a project</h1>
<p><em>Debugging</em> a project is the process of monitoring program execution. There are several methods of debugging:</p>
<ul>
<li><a class="el" href="direct_sec.html#debug_static">Static Debugging</a> - halt execution before inspecting the state.</li>
<li><a class="el" href="direct_sec.html#debug_real_time">Real-Time Debugging</a> - inspect the state while target is executing. Real-Time Debugging is possible in <b>uVision</b> via the <b>Real-Time Agent</b>.</li>
</ul>
<h2><a class="anchor" id="debug_static"></a>
Static Debugging</h2>
<p>Inspect the application state when execution has been halted. Follow these steps for static debugging:</p>
<ul>
<li>Enter debug mode with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a5a7714ee64262978b9be6d3404cc5958">UV_DBG_ENTER</a></li>
<li>&lt;&lt;set breakpoints&gt;&gt;</li>
<li>Start execution with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368aa74911091153121ba43d315242b4cd97">UV_DBG_START_EXECUTION</a></li>
<li>Wait for the <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a4fe58fe2a8b9211e23ce13dbfb7c8a74">UV_DBG_STOP_EXECUTION</a> message to arrive, indicating the target program has hit a breakpoint.</li>
<li>Stop execution with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a4fe58fe2a8b9211e23ce13dbfb7c8a74">UV_DBG_STOP_EXECUTION</a></li>
<li>Inspect memory with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a6117b2c5d860a272f81c07ce4a5de64b">UV_DBG_MEM_READ</a> or modify it with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a7f26e4bc0e9b0260d920326e5b853083">UV_DBG_MEM_WRITE</a>. The <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368ad458cf1743e81e7a00aec63bc4b0ebcd">UV_DBG_CALC_EXPRESSION</a> message is useful for resolving symbol addresses or calculating the value of code expressions.</li>
<li>Step execution with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a7ced28bf26804f88d8b83bd104f6f3fa">UV_DBG_STEP_HLL</a>, <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368ac038b3d1fe67a750e704d1b741f487ee">UV_DBG_STEP_INTO</a>, <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368abd8dd4fda941ef1a838a5eee8b62b0ff">UV_DBG_STEP_INSTRUCTION</a>, and <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368aed8089df95a591cb2552c4cfb004b7e1">UV_DBG_STEP_OUT</a>, waiting for the <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a4fe58fe2a8b9211e23ce13dbfb7c8a74">UV_DBG_STOP_EXECUTION</a> message after issuing each step command.</li>
<li>Restart execution with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368aa74911091153121ba43d315242b4cd97">UV_DBG_START_EXECUTION</a></li>
<li>Exit debug mode with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a33985645dd47599ee448bb6e26543484">UV_DBG_EXIT</a></li>
</ul>
<h2><a class="anchor" id="debug_real_time"></a>
Real-Time Debugging</h2>
<p>Inspect the application state while the target is executing. Follow these steps for real-time debugging:</p>
<ul>
<li>Enter debug mode with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a5a7714ee64262978b9be6d3404cc5958">UV_DBG_ENTER</a></li>
<li>Start execution with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368aa74911091153121ba43d315242b4cd97">UV_DBG_START_EXECUTION</a></li>
<li>Inspect memory with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a6117b2c5d860a272f81c07ce4a5de64b">UV_DBG_MEM_READ</a> or modify it with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a7f26e4bc0e9b0260d920326e5b853083">UV_DBG_MEM_WRITE</a>. The <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368ad458cf1743e81e7a00aec63bc4b0ebcd">UV_DBG_CALC_EXPRESSION</a> message is useful for resolving symbol addresses or calculating the value of code expressions.</li>
<li>If the target program contains the <b>Real-Time Agent</b> (only available for non-Arm targets), debug information from the operating system and auto-generated code structures can be received at any time via the <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368af32af2fca9c311acbbca44cf70e59894">UV_RTA_MESSAGE</a> message.</li>
</ul>
<p>To communicate with the target via a serial interface, use any UART or the <b>Real-Time Agent</b> Terminal in simulation or target mode:</p>
<ul>
<li>Send serial data to the target with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a3754afac4232b121cd2d54bceea97b57">UV_DBG_SERIAL_PUT</a></li>
<li>Receive serial data from the target with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a9c6d730a4865dc38f66b1432ddb4a415">UV_DBG_SERIAL_GET</a></li>
</ul>
<p>To exit debugging mode:</p>
<ul>
<li>Stop execution with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a4fe58fe2a8b9211e23ce13dbfb7c8a74">UV_DBG_STOP_EXECUTION</a></li>
<li>Exit debug mode with <a class="el" href="group__operation__codes.html#gga99cef9125743ebfba84222416cdeb368a33985645dd47599ee448bb6e26543484">UV_DBG_EXIT</a></li>
</ul>
<h1><a class="anchor" id="evr_data"></a>
Accessing Event Recorder Data</h1>
<p><a href="https://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank">Event Recorder</a> shows the dynamic behavior of software components that helps you to analyze the internal operation. Using the UVSOCK interface, it is possible to gain access to the Event Recorder data:</p>
<ul>
<li>Register to receive Event Records: <div class="fragment"><div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368a16c7ec87b5f7fc349fc080a16020afc2">UV_DBG_EVTR_REGISTER</a> = 0x2035       <span class="comment">// Register to receive the Event Recorder Data</span></div>
<div class="line">                                    <span class="comment">// Request  format: no data</span></div>
<div class="line">                                    <span class="comment">// Response format: #UVSOCK_CMD_RESPONSE --&gt; no data / #UVSOCK_ERROR_RESPONSE</span></div>
</div><!-- fragment --></li>
<li>Unregister to receive Event Records: <div class="fragment"><div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368a7dc0f477e22c3ef9bb967175fc0d4cfc">UV_DBG_EVTR_UNREGISTER</a> = 0x2036     <span class="comment">// Unregister to not receive the data sent from Event Recorder anymore</span></div>
<div class="line">                                    <span class="comment">// Request  format: no data</span></div>
<div class="line">                                    <span class="comment">// Response format: #UVSOCK_CMD_RESPONSE --&gt; no data / #UVSOCK_ERROR_RESPONSE</span></div>
</div><!-- fragment --></li>
<li>Check the current Event Recorder status: <div class="fragment"><div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368a8f158745bcc256f05de5584ef8553c54">UV_DBG_EVTR_GETSTATUS</a> = 0x2037      <span class="comment">// Status of Event Recorder</span></div>
<div class="line">                                    <span class="comment">// Request  format: no data</span></div>
<div class="line">                                    <span class="comment">// Response format #UVSOCK_CMD_RESPONSE --&gt; no data / #UVSOCK_ERROR_RESPONSE</span></div>
</div><!-- fragment --></li>
<li>Get the list of active SCVD files: <div class="fragment"><div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368a56f47d305c8d71dee8f033a993379123">UV_DBG_EVTR_ENUMSCVDFILES</a> = 0x2038  <span class="comment">// Get SCVD files</span></div>
<div class="line">                                    <span class="comment">// Request  format: no data</span></div>
<div class="line">                                    <span class="comment">// Response format: #UVSOCK_CMD_RESPONSE --&gt; no data / #UVSOCK_ERROR_RESPONSE</span></div>
</div><!-- fragment --></li>
</ul>
<p>The interface will answer with these responses to the requests:</p>
<ul>
<li>Response to registering events: <div class="fragment"><div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368a80ab7848f25ff5073e1fe9f0dc47af90">UV_DBG_EVTR_OUTPUT</a> = 0x5063               <span class="comment">// Notification of Event Recorder Data</span></div>
<div class="line">                                          <span class="comment">// Async format : #EVTROUT</span></div>
</div><!-- fragment --></li>
<li>Response to requesting SCVD files: <div class="fragment"><div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368a8513edb27a9e22df94a28728a0a223ba">UV_DBG_EVTR_ENUMSCVDFILES_START</a> = 0x5064, <span class="comment">// Start of available view enumeration</span></div>
<div class="line">                                          <span class="comment">// Async format : no data</span></div>
<div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368af35f28f80ad1f42e514e8b2350ed44bb">UV_DBG_EVTR_ENUMSCVDFILES_ENU</a> = 0x5065,   <span class="comment">// View list enumeration; one or more Response(s) with view item information</span></div>
<div class="line">                                          <span class="comment">// Async format : #UVSOCK_CMD_RESPONSE --&gt; #SSTR / #UVSOCK_ERROR_RESPONSE</span></div>
<div class="line"><a class="code" href="UVSOCK_8h.html#ga99cef9125743ebfba84222416cdeb368a37450162147cae552f84b51eb141dc6a">UV_DBG_EVTR_ENUMSCVDFILES_END</a> = 0x5066,   <span class="comment">// End of task list enumeration</span></div>
<div class="line">                                          <span class="comment">// Async format : no data</span></div>
</div><!-- fragment --> </li>
</ul>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Mon Jul 2 2018 08:45:40 for Using the µVision Socket Interface by ARM Ltd. All rights reserved.
	<!--
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 
	-->
	</li>
  </ul>
</div>
</body>
</html>
